﻿using System;
using Windows.ApplicationModel.Store;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;

namespace CityDashboard.Converters
{
    public class PercentageToWidthConverter : DependencyObject, IValueConverter
    {
        public int MaxWidth
        {
            get { return (int)GetValue(MaxWidthProperty); }
            set { SetValue(MaxWidthProperty, value); }
        }

        // Using a DependencyProperty as the backing store for MaxWidth.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty MaxWidthProperty =
            DependencyProperty.Register("MaxWidth", typeof(int), typeof(PercentageToWidthConverter), new PropertyMetadata(200));


        public object Convert(object value, Type targetType, object parameter, string language)
        {
            double percentage = (double)value;
            return MaxWidth * percentage;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
